package mtt.control;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDletStateChangeException;

import mtt.MobileTimeTable;

public class ApplicationController {

	/**
	 * enthält die einzige Application-Controller instanz
	 */
	private static final ApplicationController applicationController = new ApplicationController();

	/**
	 * DisplayController instance
	 */
	private static final DisplayController displayController = DisplayController
			.getInstance();

	public static final ApplicationController getInstance() {
		return applicationController;
	}

	/**
	 * enthält die MIDlet instanz
	 */
	private MobileTimeTable midlet;

	private ApplicationController() {

	}

	/**
	 * beendet die Anwendung
	 */
	public void applicationShutdown() {
		try {
			this.midlet.applicationShutdown();
		} catch (MIDletStateChangeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public DisplayController getDisplayController() {
		return displayController;
	}

	public final void setDisplay(Display display) {
		displayController.setDisplay(display);
	}

	public void setMidlet(MobileTimeTable mobileTimeTable) {
		this.midlet = mobileTimeTable;

	}

	public void startApplication() {
		displayController.showLastView();
	}
}
